// JavaScript Document
$(function(){
	pops('.cr-homework','.cr-do-homework','#mask','.cr_do_close');
	pops('.cr-datadownload','.cr-pop-datadownload','#mask','.cr_down_close');
	pops('#kc-submit','.kc-pop','#mask','.cr_close');
	function pops(clickwho,thepop,themask,theclose){	
	$(clickwho).on('click',function()
	{
	$(themask).css({
			'width'		:	$(document).outerWidth(),
			'height'	:	$(document).outerHeight(),
			'display': 'block'
		});
    $(thepop).css({
			'left'		:	($(window).innerWidth() -  $(thepop).outerWidth()) / 2 + $(window).scrollLeft(),
			'top'		:	($(window).innerHeight() -  $(thepop).outerHeight()) / 2 + $(window).scrollTop(),
			'display': 'block'
		});
		$(window).on('scroll', function() {
			$(thepop).css({
				'left'		:	($(window).innerWidth() - $(thepop).outerWidth()) / 2 + $(window).scrollLeft(),
				'top'		:	($(window).innerHeight() - $(thepop).outerHeight()) / 2 + $(window).scrollTop()
			});
		});
		
		$(window).on('resize', function() {
			$(thepop).css({
				'left'		:	($(window).innerWidth() - $(thepop).outerWidth()) / 2 + $(window).scrollLeft(),
				'top'		:	($(window).innerHeight() - $(thepop).outerHeight()) / 2 + $(window).scrollTop()
			});
			
			$('#mask').css({
				'width'		:	$(document).outerWidth(),
				'height'	:	$(document).outerHeight()
			});
		});
		$(theclose).on('click', function() {
         $(themask).hide();
		 $(thepop).hide();
		});

	
	});
	}
	//S 个人中心优化 弹窗
	$('.popclose').on('click',function(){
		$(this).parents('.popset').fadeOut();
		$(this).parents('.popset').next('.popmask').fadeOut();
	});
	//E 个人中心优化 弹窗
	
	//S 返回旧版 弹窗
		$('.returnclose,.go-this').on('click',function(){
			$(this).parents('.popRtip').fadeOut();
			$(this).parents('.popRtip').next('.popRmask').fadeOut();
		});
	//E 返回旧版 弹窗

		
	
	
	//S 返回旧版
		$('.ud-old').on('click',function(){
			$('.popRtip').fadeIn();
			$('.popRmask').fadeIn().css({
	            'height':$(document).outerHeight()
	        });
		});
	//E 返回旧版
		
	//S 关闭右侧
	 $('.update-btn .ud-close').on('click',function(){
	  $(this).parent('div').fadeOut();
	 });
	//E 关闭右侧
});